package com.xuwang.service.impl;

import com.xuwang.dto.MonthAndCountDto;
import com.xuwang.mapper.ComplaintsGMapper;
import com.xuwang.service.ComplaintsServiceG;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ComplaintsServiceGGImpl implements ComplaintsServiceG {

    @Resource
    private ComplaintsGMapper complaintsGMapper;

    @Override
    public Map<String, Object> selectCount(Integer year) {
        Map<String, Object> map = new HashMap<>();
        List<Integer> month = new ArrayList<>();
        List<Integer> count = new ArrayList<>();
        List<MonthAndCountDto> monthAndCountDtos = complaintsGMapper.selectCount(year);
        for(MonthAndCountDto monthAndCountDto : monthAndCountDtos) {
            month.add(monthAndCountDto.getMonth());
            count.add(monthAndCountDto.getCount());
        }
        map.put("code", 200);
        map.put("msg", "查询成功");
        map.put("month", month);
        map.put("count", count);
        return map;
    }

}
